package com.wzy.controller;


import com.wzy.annotation.LimitRequest;
import com.wzy.annotation.SystemLog;
import com.wzy.domain.ResponseResult;
import com.wzy.domain.entity.Question;
import com.wzy.domain.vo.QuestionVO;
import com.wzy.service.QuestionService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/question")
public class QuestionController
{
    private final QuestionService questionService;

    /**
     * 提交文章问题
     */
    @PostMapping("/postQuestion")
    @SystemLog(basenessName = "提交文章问题")
    @LimitRequest(time = 120000, description = "两分钟后再提交")
    public ResponseResult<Void> postQuestion(@Validated @RequestBody QuestionVO questionVO)
    {
        return questionService.postQuestion(questionVO);
    }

    /**
     * 获取文章问题列表
     */
    @GetMapping("/getQuestionList")
    @SystemLog(basenessName = "获取文章问题列表")
    public ResponseResult<List<Question>> getQuestionList()
    {
        return questionService.getQuestionList();
    }

    /**
     * 删除文章问题
     */
    @DeleteMapping("/deleteQuestion/{id}")
    @SystemLog(basenessName = "删除文章问题")
    public ResponseResult<Void> deleteQuestion(@PathVariable Long id)
    {
        return questionService.deleteQuestion(id);
    }

}
